<!--
* @description  : 案件-运输信息-涉案车辆
* @descriptionDetail: 案件-运输信息-涉案车辆
* @copyright    : 浙江烟草
* @author       : sy
* @create       : 2022-08-10 16:15:38
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :isWhite="true" backText="返回" :title="typeInfo.typeName"></theme-navbar>
    <!-- #endif -->
    <view class="content">
      <view class="party-info-content">
        <view class="party-info-box">
          <u-form :model="involvedForm" :rules="rules" :errorType="errorType" ref="uForm">
            <view>
              <form-section title="车辆基本信息"></form-section>
            </view>
            <u-form-item label="车辆类型" :label-position="labelPosition" :required="isTrue" prop="carStyle">
              <dic-input 
                :keyWord="$u.dic.DIC_KEYS.C_CAR_STYLE" 
                :dicCode="involvedForm.carStyle" 
                :border="border" 
                type="select" 
                :select-open="dicSelectOpen('carStyle',$u.dic.DIC_KEYS.C_CAR_STYLE)" 
                placeholder="请选择" 
                :disabled="isDisabled" 
                v-model="involvedForm.carStyleName" 
                @changeInputModelData="(name)=>{$set(involvedForm, 'carStyleName', name)}" 
                @click="showDic($u.dic.DIC_KEYS.C_CAR_STYLE,involvedForm.carStyle,'carStyle')"
              />
            </u-form-item>
            <u-form-item class="carNumFromClass" label="车牌号" :label-position="labelPosition" :required="isTrue" prop="carNum">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.carNum" />
              <auto-input
                tplClass="tp-class"
                :disabled="isDisabled"
                absIndex="1"
                :searchData="searchCarNumData"
                absClass="carNumFromClass"
                placeholder="请输入车牌号"
                v-model="involvedForm.carNum"
                @choiceAutoItem="choiceAutoItem"
              >
              </auto-input>
            </u-form-item>
            <u-form-item label="品牌型号" :label-position="labelPosition">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.carFeature" />
            </u-form-item>
            <u-form-item label="车辆颜色" :label-position="labelPosition">
              <dic-input :keyWord="$u.dic.DIC_KEYS.C_CAR_COLOR" :dicCode="involvedForm.carColor" :border="border" type="select" :select-open="dicSelectOpen('carColor',$u.dic.DIC_KEYS.C_CAR_COLOR)" placeholder="请选择" :disabled="isDisabled" v-model="involvedForm.carColorName" @changeInputModelData="(name)=>{$set(involvedForm, 'carColorName', name)}" @click="showDic($u.dic.DIC_KEYS.C_CAR_COLOR,involvedForm.carColor,'carColor')" />
            </u-form-item>	
            <u-form-item label="车辆识别码" :label-position="labelPosition" prop="engineNo">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.engineNo" />
            </u-form-item>
            <u-form-item label="车牌号真假" label-width="220" label-position="left">
              <view class="u-sub-btn" slot="right">
                <u-switch size="40" :disabled="isDisabled" v-model="carNumAuthen" @change="switchChange($event,'isCarNumAuthen','carNumAuthen')"></u-switch>
              </view>
            </u-form-item>	
            <u-form-item label="假车牌号描述" :label-position="labelPosition" v-if="!carNumAuthen">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.fakeCarNum" />
            </u-form-item>
            
            <view style="margin: 0px -16px;">
              <u-gap :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            </view>
            <view>
              <form-section title="车主信息"></form-section>
            </view>
            <u-form-item label="姓名(企业名称)" :label-position="labelPosition" prop="owner">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.owner" />
            </u-form-item> 
            <u-form-item label="性别" :label-position="labelPosition">
              <dic-input :keyWord="$u.dic.DIC_KEYS.BSC_GENDDER" :dicCode="involvedForm.ownerSex" :border="border" type="select" :select-open="dicSelectOpen('ownSex',$u.dic.DIC_KEYS.BSC_GENDDER)" placeholder="请选择" :disabled="isDisabled" v-model="involvedForm.ownerSexName" @changeInputModelData="(name)=>{$set(involvedForm, 'ownerSexName', name)}" @click="showDic($u.dic.DIC_KEYS.BSC_GENDDER,involvedForm.ownerSex,'ownSex')" />	
            </u-form-item>
            <u-form-item label="身份证号" :label-position="labelPosition" prop="ownerIdCard">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.ownerIdCard" />
            </u-form-item>
            <u-form-item label="行驶证号" :label-position="labelPosition">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.carLice" />
            </u-form-item>
            <u-form-item label="电话" :label-position="labelPosition" prop="ownerPhone">
              <u-input placeholder="请填写电话" :disabled="isDisabled" v-model="involvedForm.ownerPhone" />
            </u-form-item> 
            <u-form-item label="车主籍贯" :label-position="labelPosition">
              <view class="logi-addr">
                <u-input
                  type="select"
                  :disabled="true"
                  placeholder="车主籍贯地址选择"
                  v-model="ownerCoinNames"
                  @click="clickAreaShow('owner')"
                ></u-input>
              </view>
            </u-form-item>

            <view style="margin: 0px -16px;">
              <u-gap :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            </view>
            <view>
              <form-section title="驾驶员信息" rightIcon="plus-people-fill" @rightTap="athPersonClick"></form-section>
            </view>
            <view class="">
              <u-table font-size="26" style="border-left: none;">
                <u-tr class="u-tr border-left">
                  <u-th class="u-th" width="30%">
                    姓名
                  </u-th>
                  <u-th class="u-th">
                    涉案关系
                  </u-th>
                  <u-th class="u-th">
                    涉案类别
                  </u-th>
                  <!-- <u-th class="u-th">
                    参与角色
                  </u-th> -->
                  <u-th class="u-th">
                    联系电话
                  </u-th>
                </u-tr>
                <u-tr v-for="(itm,idx) in partyList" :key="'partyList'+idx" class="u-tr border-left" :class="[idx == 0 ? 'border-Top' : '']">
                  <u-td class="u-td" width="30%" style="color: #2979ff;">
                    <text @click="itemDetail(itm)">
                      {{ itm.partyName || '&nbsp;' }}
                    </text>
                  </u-td>
                  <u-td class="u-td">
                    {{ itm.roleOfCaseName|| '&nbsp;' }}
                  </u-td>
                  <u-td clas="u-td">
                    {{ itm.partyTypeName|| '&nbsp;' }}
                  </u-td>
                  <!-- <u-td class="u-td">
                    {{ itm.partakeRoleName|| '&nbsp;' }}
                  </u-td> -->
                  <u-td class="u-td">
                    {{ itm.phone|| '&nbsp;' }}
                  </u-td>
                </u-tr>
              </u-table>
            </view>
            
            <view style="margin: 0px -16px;">
              <u-gap :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            </view>
            <view>
              <form-section title="车辆运输信息"></form-section>
            </view>
            <u-form-item label="登记单位" :label-position="labelPosition" :required="isTrue" prop="orgName" right-icon="arrow-down-fill" :right-icon-style="iconStyle">
              <u-input
                :disabled="isDisabled"
                placeholder="请选择"
                v-model="involvedForm.orgName"
                @click="orgSelectShow = true"
              >
              </u-input>
            </u-form-item>
            <u-form-item label="运输路线起点" :label-position="labelPosition">
              <view class="logi-addr">
                <u-input
                  type="select"
                  :disabled="true"
                  placeholder="运输起点行政区划选择"
                  v-model="trSCoinNames"
                  @click="clickAreaShow('trS')"
                ></u-input>
                <u-line :color="$theme.u_border_color" style="margin: 10rpx 0;"></u-line>
                <u-row gutter="16">
                  <u-col span="12">
                    <u-input :border="true" placeholder="街道" v-model="involvedForm.transStStreet"></u-input>
                  </u-col>
                </u-row>
              </view>
            </u-form-item>
            <form-section
              @rightTap="clickAreaShow('way')"
              title="运输路线途经点"
              :rightIcon="isDisabled ? '' : 'plus-circle'"
              :rightIconSize="40"
            ></form-section>
            <u-form-item>
              <u-table>
                <u-tr>
                  <u-th :width="!isDisabled ? '40%' : '60%'">
                    途径省市县
                  </u-th>
                  <u-th width="40%">
                    街道
                  </u-th>
                  <u-th v-if="!isDisabled">
                    操作
                  </u-th>
                </u-tr>
                <u-tr v-for="(item, index) in wayAddrList" :key="item.index">
                  <u-td :width="!isDisabled ? '40%' : '60%'">
                    {{ item.wayCoinNames || "&nbsp;" }}
                  </u-td>
                  <u-td width="40%">
                    <u-input :border="true" :disabled="isDisabled" placeholder="街道" v-model="item.wayStreet"></u-input>
                  </u-td>
                  <u-td style="color: #fa3534" v-if="!isDisabled">
                    <text @click="channelDel(index)">
                      删除
                    </text>
                  </u-td>
                </u-tr>
              </u-table>
            </u-form-item>
            <u-form-item label="运输路线终点" :label-position="labelPosition">
              <view class="logi-addr">
                <u-input
                  type="select"
                  :disabled="true"
                  placeholder="运输终点行政区划选择"
                  v-model="trECoinNames"
                  @click="clickAreaShow('trE')"
                ></u-input>
                <u-line :color="$theme.u_border_color" style="margin: 10rpx 0;"></u-line>
                <u-row gutter="16">
                  <u-col span="12">
                    <u-input :border="true" placeholder="街道" v-model="involvedForm.transEndStreet"></u-input>
                  </u-col>
                </u-row>
              </view>
            </u-form-item>
            <view style="margin: 0px -16px;">
              <u-gap :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            </view>
            <view>
              <form-section title="车辆描述信息"></form-section>
            </view>

            <u-form-item label="车辆描述" :label-position="labelPosition" prop="carDesc">
              <u-input placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.carDesc" />
            </u-form-item>

            <view style="margin: 0px -16px;">
              <u-gap :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            </view>
            <!-- <view>
              <form-section title="备注信息"></form-section>
            </view>

            <u-form-item :label-position="labelPosition" label="备注">
              <u-input type="textarea" height="100" :auto-height="true" placeholder="请输入" :disabled="isDisabled" v-model="involvedForm.remark" />				
            </u-form-item> -->

            <view style="margin: 0px -16px;">
              <u-gap :height="$theme.cm_gap_height" :bg-color="$theme.cm_gap_color"></u-gap>
            </view>
            <view>
              <form-section title="图片信息"></form-section>
            </view>

            <u-form-item label="车辆照片" :label-position="labelPosition">
              <view class="zk-img-content">
                <m-upload
                  :deletable="true"
                  :maxCount="picIds"
                  width="150rpx"
                  height="150rpx"
                  :file-list="fileList"
                  :multiple="true"
                  index="fileList"
                  :uploadParam="{'fiGroupCode':$FILE_GROUP_TYPE.c_case_car}"
                  upApiUrl="uploadBase64ForApp"
                  @on-list-change="changeUpload"
                >
                </m-upload>
              </view>
            </u-form-item>

            <u-form-item label="驾驶证照片" :label-position="labelPosition">
              <view class="zk-img-content">
                <m-upload
                  :deletable="true"
                  :maxCount="picIds"
                  width="150rpx"
                  height="150rpx"
                  :file-list="driveCarFileList"
                  :multiple="true"
                  index="driveCarFileList"
                  :uploadParam="{'fiGroupCode':$FILE_GROUP_TYPE.c_case_car}"
                  upApiUrl="uploadBase64ForApp"
                  @on-list-change="changeUpload"
                >
                </m-upload>
              </view>
            </u-form-item>

            <u-form-item label="行驶证照片" :label-position="labelPosition">
              <view class="zk-img-content">
                <m-upload
                  :deletable="true"
                  :maxCount="picIds"
                  width="150rpx"
                  height="150rpx"
                  :file-list="travelCarFileList"
                  :multiple="true"
                  index="travelCarFileList"
                  :uploadParam="{'fiGroupCode':$FILE_GROUP_TYPE.c_case_car}"
                  upApiUrl="uploadBase64ForApp"
                  @on-list-change="changeUpload"
                >
                </m-upload>
              </view>
            </u-form-item>
          </u-form>
        </view>
      </view>
      <view class="space-content"></view>
      <view class="submit-btns btn-other-cls">
        <u-button class="u-btn" type="primary" v-if="typeInfo.type!='view'" @click="confirm">
          保存
        </u-button>
      </view>
    </view>
    <u-popup mode="bottom" height="70%" v-model="partyShow">
      <m-select :isSingle="false" :options="orginalPartyList" :defaultUids="defaultPartyUids" title="涉案人选择" :hasExts="true" @select="partySelect"></m-select>
    </u-popup>
    <!-- 行政区划选择 -->
    <u-popup mode="bottom" height="80%" v-model="nativeNameSelectShow">
      <area-select @choose="nativeNameSelectShowComfir"></area-select>
    </u-popup>
    <dic-choice :keyWord="dicKeyWords" :currentSelect="dicCurrentSelect" v-model="dicShow" @confirm="selectDicConfirm"></dic-choice>
    <!-- 组织机构选择 -->
    <u-popup mode="bottom" height="80%" v-model="orgSelectShow">
      <org-select :cleanParentOrg="true" :isHybrid="true" limitNodeType="03" treeType="zm-comp" @choose="handlerChooseOrg"></org-select>
    </u-popup>
    <u-popup mode="bottom" height="30%" v-model="detailShow">
      <view class="content" style="padding: 40rpx;">
        <view style="position: fixed;top: 0;width: 100%;height: 30rpx;background-color: white;"></view>
        <view style="padding-bottom: 120rpx;">
          <u-row gutter="16">
            <u-col span="12">
              <text style="font-size: 30rpx;">
                姓名/企业名称: {{ detailData.partyName }}
              </text>
            </u-col>
          </u-row>
          <u-row gutter="16">
            <u-col span="6">
              <text style="font-size: 24rpx;color: #666666;">
                涉案关系: {{ detailData.roleOfCaseName }}
              </text>
            </u-col>
            <u-col span="6">
              <text style="font-size: 24rpx;color: #666666;">
                涉案人类别: {{ detailData.partyTypeName }}
              </text>
            </u-col>
          </u-row>
          <u-row gutter="16">
            <u-col span="6">
              <text style="font-size: 24rpx;color: #666666;">
                参与角色: {{ detailData.partakeRoleName }}
              </text>
            </u-col>
            <u-col span="6">
              <text style="font-size: 24rpx;color: #666666;">
                联系电话: {{ detailData.phone }}
              </text>
            </u-col>
          </u-row>
          <u-row gutter="16">
            <u-col span="12">
              <text style="font-size: 24rpx;color: #666666;">
                经营地址: {{ detailData.busiAddr }}
              </text>
            </u-col>
          </u-row>
        </view>
      </view>
    </u-popup>
  </view>
</template>

<script>
import DicChoice from "@/components/dic_choice.vue";
import DicInput from "@/components/dic_input.vue";
import TcarInfo from "@/declare/case/TcarInfo.js";
import commonService from "@/service/common/common.service";
import caseService from '@/service/case/case.service.js';
import areaSelect from "@/components/area-select.vue";
import FormSection from "@/components/form-section.vue";
import mUpload from '@/components/m-upload.vue';
import OrgSelect from "@/components/org-select.vue";
import MSelect from "@/components/m-select.vue";
import AutoInput from "@/components/autoInput.vue";
import { v4 as uuidv4, } from "uuid";
export default {
  components:{
    areaSelect,
    "dic-choice":DicChoice,
    "dic-input":DicInput,
    FormSection,
    mUpload,
    OrgSelect,
    MSelect,
    AutoInput,
  },
  data(){
    return {
      partyShow:false,
      nativeNameSelectShow: false,// 行政区选择框是否打开
      ownerCoinNames: "",// 车主籍贯
      driverCoinNames: "",// 驾驶员籍贯
      wayAddrList:[],
      trSCoinNames: "",// 运输路线起始地址
      trECoinNames: "",// 运输路线终点地址
      carChecked:false,// 是否改装车
      dicType:"car",
      dicShow: false, // dic_select 是否显示
      dicKeyWords: "", // dic 关键字
      dicCurrentSelect: "", // dic 当前选择项
      isDisabled:false, // 表单是否禁用
      involvedForm:TcarInfo.createNew(),
      rules:{
        carNum: [{
          required: true,
          message: '请输入车牌号',
          trigger: ['change', 'blur',],
        },{
          message:"车牌号格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.involvedForm.carStyle == '09'){
              return true;
            }
            return this.$u.test.carNo(value);
          },
        },],
        dicCarType: [{
          required: true,
          message: '请选择涉案关系',
          trigger: ['change', 'blur',],
        },],
        carStyle: [{
          required: true,
          message: '请输入车型',
          trigger: ['change', 'blur',],
        },],
        ownerPhone:[{
          validator: () => {
            if(this.involvedForm.ownerPhone){
              return this.$u.test.mobile(this.involvedForm.ownerPhone);
            }else{
              return true;
            }
          },
          message: '车主电话不正确',
          trigger: ['change','blur',],
        },],
        driverPhone:[{
          validator: () => {
            if(this.involvedForm.driverPhone){
              return this.$u.test.mobile(this.involvedForm.driverPhone);
            }else{
              return true;
            }
          },
          message: '驾驶员电话不正确',
          trigger: ['change','blur',],
        },],
        driverIdCard: [{
          validator: () => {
            if ( this.involvedForm.driverIdCard) {
              return this.$u.test.idCard(this.involvedForm.driverIdCard);
            } else {
              return true;
            }
          },
          message: '驾驶员身份证号码不正确',
          trigger: ['change', 'blur',],
        },],
        ownerIdCard: [{
          validator: () => {
            if (this.involvedForm.ownerIdCard) {
              return this.$u.test.idCard(this.involvedForm.ownerIdCard);
            } else {
              return true;
            }
          },
          message: '车主身份证号码不正确',
          trigger: ['change', 'blur',],
        },],
        owner: [{
          message:"姓名格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }
            let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
            return regs.test(value);
          },
        },],
        driverLicNo: [{
          required: true,
          message: '请输入驾驶证号',
          trigger: ['change', 'blur',],
        },{
          message:"驾驶证号格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            let regs = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}(\d|x|X)$/;
            return regs.test(value);
          },
        },],
        orgName: [{
          required: true,
          message: '请选择登记单位',
          trigger: 'change',
        },],
        driver: [{
          required: true,
          message: '请输入驾驶员姓名',
          trigger: ['change', 'blur',],
        },{
          message:"姓名格式不正确！",
          trigger: ['change', 'blur',],
          validator: (rule, value, callback) => {
            if(this.$u.test.isEmpty(value)){
              return true;
            }
            let regs = /^[a-zA-Z\u4e00-\u9fa5]+$/;
            return regs.test(value);
          },
        },],
        transportStyleName: [{
          required: true,
          message: '请选择运输类型',
          trigger: ['change', 'blur',],
        },],
      },
      errorType: ['border-bottom','message',],
      isTrue: true,
      labelPosition:"top",
      activeColor: this.$u.color['primary'],
      border: false,
      typeInfo:{},// 类型 添加/编辑
      areaType:'',// 行政区划弹窗类型
      fileList: [],
      driveCarFileList: [],
      travelCarFileList:[],
      picIds: '20',
      iconStyle:{
        color: '#c0c4cc',
      },
      orgSelectShow:false, // 等级单位控制
      carNumAuthen:false,
      detailData:{},
      detailShow:false,
      partyList:[], // 驾驶人信息
      orginalPartyList:[], // 案件涉案人列表
      defaultPartyUids:[],
    }
  },
  onReady() {
    this.$refs.uForm.setRules(this.rules);
  },
  // 加载初始周期方法
  onLoad(opt) {
    let prevParam =  this.getRouteParam();
    this.involvedForm.caseUuid = prevParam.caseUuid;
    if (prevParam.type) {
      this.typeInfo.type = prevParam.type;
      this.typeInfo.typeName = prevParam.type == 'add' ? "添加涉案车辆" :  "编辑涉案车辆";
    } else {
      this.typeInfo = {};
    }
    this.getPartyInfoList();
    if(prevParam.carUuid){
      this.$modal.showLoading('加载中...');
      caseService.carRelationInfo({
        carUuid: prevParam.carUuid,
      }).then(rs => {
        this.$modal.hideLoading();
        if(rs.success){
          this.involvedForm = rs.bean.car || {};
          if(!this.$u.test.isEmpty(this.involvedForm.partyUuids)){
            this.defaultPartyUids = this.involvedForm.partyUuids.split(',');
          }
          this.carNumAuthen = this.involvedForm.isCarNumAuthen == 'true' || this.involvedForm.isCarNumAuthen;
          if (this.involvedForm.carPhoto) {
            let photoArr = this.involvedForm.carPhoto.split(',');
            photoArr.forEach((val) => {
              this.fileList.push({
                gfiId: val,
              });
            });
          }
          if (this.involvedForm.driveCarPhoto) {
            let driveCarArr = this.involvedForm.driveCarPhoto.split(',');
            driveCarArr.forEach((val) => {
              this.driveCarFileList.push({
                gfiId: val,
              });
            });
          }
          if (this.involvedForm.travelCarPhoto) {
            let travelCarPhotoArr = this.involvedForm.travelCarPhoto.split(',');
            travelCarPhotoArr.forEach((val) => {
              this.travelCarFileList.push({
                gfiId: val,
              });
            });
          }
          if(!this.$u.test.isEmpty(this.involvedForm.wayProv)){
            this.initWayArea(this.involvedForm.wayProv || '',this.involvedForm.wayCity || '',this.involvedForm.wayCounty || '',this.involvedForm.wayStreet || '');
          }
          this.init();
          this.partyList = rs.bean.casePartyInfoList || [];
        }else{
          this.$u.toast(rs.msg);
        }
      }).catch(e => {
        this.$modal.hideLoading();
        this.$u.toast('加载失败');
        console.log(e);
      });
    }
  },
  methods:{
    channelDel(i) {
      this.wayAddrList.splice(i, 1);
    },
    searchCarNumData(txt) {
      return new Promise((resolve, reject) => {
        if(txt.length < 3){ // 搜索内容小于3个 不进行模糊匹配
          resolve([]);
          return;
        }
        caseService.getCaseCarList({
          name:txt,
          page:1,
          limit: 10,
        }).then((res) => {
          if (res.success) {
            let tmp = res.data;
            tmp.forEach((itm) => {
              itm.name = itm.carNum;
              itm.id = uuidv4();
            });
            resolve(tmp);
          } else {
            resolve([]);
          }
        }).catch((err) => {
          resolve([]);
        });
      });
    },
    choiceAutoItem(itm, index) {
      if (index == "1") {
        this.involvedForm.carStyle = itm.carStyle;
        this.involvedForm.carNum = itm.carNum;
        this.involvedForm.carFeature = itm.carFeature;
        this.involvedForm.carColor = itm.carColor;
        this.involvedForm.engineNo = '';
        this.involvedForm.isCarNumAuthen = false;
        this.carNumAuthen = false;
      }
    },
    partySelect(e){
      this.partyShow = false;
      this.partyList = e.map(ip => {
        return ip.obj;
      });
      this.defaultPartyUids = this.partyList.map(ix => {
        return ix.partyUuid;
      });
    },
    athPersonClick(){
      if(this.isDisabled) return;
      this.partyShow = true;
    },
    itemDetail(obj) {
      this.detailData = obj;
      this.detailShow = true;
    },
    // 获取当事人list（多选）
    getPartyInfoList() {
      caseService.getPartyInfoList(this.involvedForm.caseUuid).then(res => {
        if (!res.success) return;
        this.orginalPartyList = res.data.map(itm => {
          return {
            uid: itm.partyUuid,
            name: itm.partyName,
            exts:[
              {key:'负责人', value: itm.picPerson || '',},
              {key:'涉案关系', value: itm.roleOfCaseName || '',},
              {key:'涉案类别', value: itm.partyTypeName || '',},
              {key:'联系电话', value: itm.phone || '',},
            ],
            obj: itm,
          };
        });
      }).catch((err) => {
        console.log(err);
      });
    },
    init() {
      this.initAreaData(this.involvedForm.driverProv,this.involvedForm.driverCity,this.involvedForm.driverCounty,'driverCoinNames');
      this.initAreaData(this.involvedForm.nativeProv,this.involvedForm.nativeCity,this.involvedForm.nativeCounty,'ownerCoinNames');
      this.initAreaData(this.involvedForm.transStProv,this.involvedForm.transStCity,this.involvedForm.transStCounty,'trSCoinNames');
      this.initAreaData(this.involvedForm.transEndProv,this.involvedForm.transEndCity,this.involvedForm.transEndCounty,'trECoinNames');
    },
    initAreaData(provCode,cityCode,countyCode,name){
      if(!this.$u.test.isEmpty(provCode) && !this.$modal.isMuniCity(provCode)){
        this[name] = commonService.getPersonLocal(provCode, true).areaName || "";
      }
      if(!this.$u.test.isEmpty(cityCode)){
        this[name] += commonService.getPersonLocal(cityCode, true).areaName || "";
      }
      if(!this.$u.test.isEmpty(countyCode)){
        this[name] += commonService.getPersonLocal(countyCode, true).areaName || "";
      }
    },
    initWayArea(provWayArr, cityWayArr, countryWayArr, wayStreetArr){
      this.wayAddrList = [];
      let provs = provWayArr.split(',');
      let citys = cityWayArr.split(',');
      let countrys = countryWayArr.split(',');
      let streets = wayStreetArr.split(',');
      for (let i = 0; i < provs.length; i ++) {
        let wayObj = {wayCity:'',wayCounty:'',};
        let names = "";
        if(!this.$u.test.isEmpty(provs[i]) && !this.$modal.isMuniCity(provs[i])){
          names = commonService.getPersonLocal(provs[i], true).areaName || "";
        }
        if(i < citys.length && !this.$u.test.isEmpty(citys[i])){
          names += commonService.getPersonLocal(citys[i], true).areaName || "";
          this.$set(wayObj, 'wayCity', citys[i]);
        }
        if(i < countrys.length && !this.$u.test.isEmpty(countrys[i])){
          names += commonService.getPersonLocal(countrys[i], true).areaName || "";
          this.$set(wayObj, 'wayCounty', countrys[i]);
        }
        this.$set(wayObj, 'wayCoinNames', names);
        this.$set(wayObj, 'wayProv', provs[i]);
        this.$set(wayObj, 'wayStreet', i < streets.length ? (streets[i] || '') : '');
        this.wayAddrList.push(wayObj);
      }
    },
    handlerChooseOrg(orgs) {
      this.involvedForm.orgUuid = orgs[0].id;
      this.involvedForm.orgName = orgs[0].name;
      this.orgSelectShow = false;
    },
    dicSelectOpen: function (type,keyWords) {
      if(type == this.dicType){
        if (this.dicKeyWords == keyWords && this.dicShow) {
          return true;
        }
        return false;
      }
    },
    showDic: function (key, cur,type) {
      if (this.dicShow) return;
      this.dicKeyWords = key;
      this.dicCurrentSelect = cur;
      this.dicShow = true;
      this.dicType = type;
    },
    selectDicConfirm: function (e) {
      if(this.dicKeyWords == this.$u.dic.DIC_KEYS.BSC_GENDDER){
        if(this.dicType == 'ownSex'){
          this.involvedForm.ownerSex = e[0].extra.bcbCode;
          this.involvedForm.ownerSexName = e[0].label;
        }else{
          this.involvedForm.driverSex = e[0].extra.bcbCode;
          this.involvedForm.driverSexName = e[0].label;
        }
      }else if(this.dicKeyWords == this.$u.dic.DIC_KEYS.C_DIC_CAR_TYPE){
        this.involvedForm.dicCarType = e[0].extra.bcbCode;
        this.involvedForm.dicCarName = e[0].label;
      }else if(this.dicKeyWords == this.$u.dic.DIC_KEYS.C_CAR_STYLE){
        this.involvedForm.carStyle = e[0].extra.bcbCode;
        this.involvedForm.carStyleName = e[0].label;
      }else if(this.dicKeyWords == this.$u.dic.DIC_KEYS.C_CAR_COLOR){
        this.involvedForm.carColor = e[0].extra.bcbCode;
        this.involvedForm.carColorName = e[0].label;
      }else if(this.dicKeyWords == this.$u.dic.DIC_KEYS.K_TRANSPORT_STYLE){
        this.involvedForm.transportStyle = e[0].extra.bcbCode;
        this.involvedForm.transportStyleName = e[0].label;
      }
    },
    // 选择行政区划弹窗
    clickAreaShow(type){
      this.areaType = type;
      this.nativeNameSelectShow = true;
    },
    nativeNameSelectShowComfir(areas) {
      let wayObj = {};
      switch (this.areaType) {
      case 'owner':
        this.fromDataCopy('ownerCoinNames','nativeProv','nativeCity','nativeCounty',areas);
        break;
      case 'driver':
        this.fromDataCopy('driverCoinNames','driverProv','driverCity','driverCounty',areas);
        break;
      case 'trS':
        this.fromDataCopy('trSCoinNames','transStProv','transStCity','transStCounty',areas);
        break;
      case 'trE':
        this.fromDataCopy('trECoinNames','transEndProv','transEndCity','transEndCounty',areas);
        break;
      case 'way':
        if(this.$modal.isMuniCity(areas[0].proCode)){
          this.$set(wayObj, 'wayCoinNames', [areas[0].admdivName, areas[0].countryName,].join(""));
        }else{
          this.$set(wayObj, 'wayCoinNames', [areas[0].proName, areas[0].admdivName, areas[0].countryName,].join(""));
        }
        this.$set(wayObj, 'wayProv', areas[0].proCode);
        this.$set(wayObj, 'wayCity', areas[0].admdivCode);
        this.$set(wayObj, 'wayCounty', areas[0].countryCode);
        this.$set(wayObj, 'wayStreet', '');
        this.wayAddrList.push(wayObj);
        break;
      }
      this.nativeNameSelectShow = false;
    },
    fromDataCopy(areaName,pro,city,coun,areas){
      if(this.$modal.isMuniCity(areas[0].proCode)){
        this[areaName] = [areas[0].admdivName, areas[0].countryName,].join("");
      }else{
        this[areaName] = [areas[0].proName, areas[0].admdivName, areas[0].countryName,].join("");
      }
      this.involvedForm[pro] = areas[0].proCode;
      this.involvedForm[city] = areas[0].admdivCode;
      this.involvedForm[coun] = areas[0].countryCode;
    },
    // switch开关
    switchChange(status,type,desc){
      this[desc] = status;
      this.involvedForm[type] = status;
      if(status){
        this.involvedForm.fakeCarNum = '';
      }
    },
    // 确认
    confirm(){
      let self = this;
      if(this.partyList.length == 0) {
        this.$u.toast('请关联驾驶员信息');
        return;
      }
      if(this.fileList.length == 0){
        this.$u.toast('请上传车辆照片');
        return;
      }
      this.involvedForm.partyUuids = this.partyList.map(itm => {
        return itm.partyUuid;
      }).join(',');
      this.$refs.uForm.validate(valid => {
        if (valid) {
          let {...params} = self.involvedForm;
          let ids = [];
          if(this.fileList.length > 0){
            this.fileList.forEach((item) => {
              ids.push(item.gfiId);
            });
            params.carPhoto = ids.join(',');
          }
          delete params.toJsonStr;
          delete params.updateContent;
          delete params.updateTime;
          console.log(params);
          caseService.saveCar(params).then(res => {
            if(res.success){
              this.$u.success('保存成功',2000,() => {
                self.backPrev({
                  paramKey: "formItem",
                  param :{
                    type:'car',
                  },
                });
              });
            }else{
              this.$u.toast(res.msg);
            }
          }).catch(err => {
            this.$u.toast(err);
          })
        } 
      });
    },
    // 上传/删除图片事件
    changeUpload(list, key) {
      if (list.length > 0) {
        this[key] = [...list,];
      } else {
        this[key] = [];
      }
    },
  },
}
</script>

<style lang="scss" scoped>
@import "../case_common.scss";
.page{ padding:0; }
.logi-addr{
display: flex;
 flex-direction: column;
 width: 100%;
}
.secion-title{
	font-size: .9rem;
	font-weight: 500;
	padding: 30rpx 0px 20rpx;
}
.u-sub-btn{
	width: 99%;
}
.border-left {
		border-left: 1px solid rgb(228, 231, 237);
	}

	.border-Top {
		border-top: 1px solid rgb(228, 231, 237);
	}
  .tp-class {
  width: 100%;
}
/deep/.u-td {
	white-space: inherit !important;
	height: auto !important;
	line-height: 30px;
}
</style>
